Demo: Managing Missing Values (Self-Paced)
In this demonstration, you learn to address missing values in the MISSING_PVA data set. The data set has quite a few variables with missing values. However, for brevity, let's focus on the Rep_DemMedIncome variable. Use the Imputation node in a flow to impute synthetic data values.
Reminder: If you restarted your SAS session, or it has timed out due to inactivity, you must re-create the course libraries,
LOCALLIB and
VST. To do this, run the
AssignLibrary flow.
- In SAS Viya, launch SAS Studio by clicking the Applications menu button (the three-by-three grid in the upper left corner), expand ANALYTICS LIFE CYCLE, and click Develop Code and Flows.
- In the navigation panel on the far left, click the Explorer button (second from top). Expand Files >Home > workshop > VST. Double-click AssignLibrary.flw to open it.
- Click the Run button on the flow toolbar.
Demo Steps
- Open the previously created flow Data Preprocessing.flw from the VST folder.
- Click on the Steps icon on the left side of the Navigation Pane. Under SAS Steps, expand Prepare Data, then double click on the Imputation step.
- Right click on the Imputation step and choose Add output port.
- Next, move your mouse towards the edge of the MISSING_PVA node until the pointer becomes a hand icon. Click and drag an arrow from MISSING_PVA node to the box on the left side of the Imputation node (the input port). Now Imputation is connected to the MISSING_PVA data.
- Add another Table step to the flow by double clicking Table under Data (Input and Output). For this node, under Table Properties, enter VST for Library and IMPUTED_PVA in the Table name field.
- Connect the output port of the Imputation node to the IMPUTED_PVA node. Use the Arrange nodes button to visually organize the nodes in the flow.

- Click on the Imputation node, then select the Data tab.
- Under Interval Variables, click the plus sign corresponding to Replace missing values with the mean and select the Rep_DemMedIncome variable. Then click OK to close the Column Selection window.
Note: Users also have the option to impute the missing values in interval variables with the median or a random number. If required, users can choose different methods for different variables.
Note: The Imputation step also supports imputing missing values in nominal variables by mode.
- Click the Output tab. Make sure Save imputed data and Replace existing output table are both selected.
Note: To expedite the demonstration in the class setup, a CAS table in the VST library has already been saved with the same name. Thus, the Replace option is used.
- Next, to include all the variables from the input CAS table in the output CAS table, click the All variables radio button under Include variables from the input CAS table.
- Click Run to execute the flow. Save the file Data Preprocessing.flw. When the run is complete, view the results in the work area. You clearly see that a new input, IM_Rep_DemMedIncome, is added to the data set, and it has missing values replaced by a synthetic value ($53513, the mean in this case) and nonmissing values copied from the original input.

- Click the Output Data tab to view a snapshot of the output table. Scroll your cursor to the right, and you see the new column, IM_Rep_DemMedIncome, that contains the value 53513 for every missing value in the Rep_DemMedIncome column. Because both the versions of the income variables are available in the data set, going forward, you should use the IM_Rep_DemMedIncome variable for analysis.
